package com.zq.create.builder;

import java.util.Objects;

public abstract class Product {
    private String name;
    private int id;

    public abstract static class Builder<B extends Builder<B>> {
        private String name;
        private int id;

        B setName(String name) {
            this.name = Objects.requireNonNull(name);
            return self();
        }

        B setId(int id) {
            this.id = id;
            return self();
        }

        protected abstract B self();

        protected abstract Product build();
    }

    protected Product(Builder<?> builder) {
        name = builder.name;
        id = builder.id;
    }

    public String getName() {
        return name;
    }

    public int getId() {
        return id;
    }
}
